@using System.ComponentModel
@using System.Text
@using BlazorDatasheet.Render
<!--Renders a box at a particular row/column with a width & height -->

<div style="@GetSizeStyleString(); position: absolute; pointer-events: none;"/>
    
@code {

    [Parameter]
    public double X { get; set; }

    [Parameter]
    public double Y { get; set; }

    [Parameter]
    public double Width { get; set; }

    [Parameter]
    public double Height { get; set; }

    [Parameter]
    public int ZIndex { get; set; }

    [Parameter]
    public double BorderThickness { get; set; }

    [Parameter]
    public string BackgroundStyle { get; set; }

    [Parameter]
    public string BorderColor { get; set; } = "var(--selection-border-color);";

    [Parameter]
    public bool BackgroundVisible { get; set; }

    private string GetSizeStyleString()
    {
        var strBuilder = new StringBuilder();

        strBuilder.Append($"left:{X}px;");
        strBuilder.Append($"top:{Y}px;");
        strBuilder.Append($"width:{Width}px;");
        strBuilder.Append($"height:{Height}px;");
        strBuilder.Append($"position:relative;");
        strBuilder.Append($"z-index:{ZIndex};");
        if (BorderThickness != 0)
        {
            strBuilder.Append($"outline: {BorderThickness}px solid {BorderColor};");
        }

        if (BackgroundVisible)
        {
            strBuilder.Append(BackgroundStyle);
        }

        var style = strBuilder.ToString();
        return style;
    }

}